<html>
<head><meta charset="utf-8"><title>Failed to implement Drop with const generics · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Failed.20to.20implement.20Drop.20with.20const.20generics.html">Failed to implement Drop with const generics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="246531411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Failed%20to%20implement%20Drop%20with%20const%20generics/near/246531411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> TennyZhuang <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Failed.20to.20implement.20Drop.20with.20const.20generics.html#246531411">(Jul 20 2021 at 00:28)</a>:</h4>
<p>Failed to implement Drop with const generics: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=b0d38ee4cbd4cbf5ef19b7f1a78aef2f">playground</a>, any solution for it?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="cp">#![feature(const_evaluatable_checked)]</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">A</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">[();</span><span class="w"> </span><span class="n">M</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span>: <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">arr</span>: <span class="p">[</span><span class="kt">i32</span><span class="p">;</span><span class="w"> </span><span class="n">M</span><span class="o">*</span><span class="mi">2</span><span class="p">],</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Drop</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">A</span><span class="o">&lt;</span><span class="n">M</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">[();</span><span class="w"> </span><span class="n">M</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span>: <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">drop</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="fm">println!</span><span class="p">(</span><span class="s">"drop"</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="246532669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Failed%20to%20implement%20Drop%20with%20const%20generics/near/246532669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Failed.20to.20implement.20Drop.20with.20const.20generics.html#246532669">(Jul 20 2021 at 00:52)</a>:</h4>
<p>I dont think there's a solution for this (<a href="https://github.com/rust-lang/rust/issues/79248">#79248</a>) pretty sure its a bug in const_evaluatable_checked</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>